<?php

class SettingController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */

	public function actionIndex()
	{	

	
		$this->render('index',array(
			'model'=>$model,
		));
	}
	
	public function actionEditsetting()
	{
		//print_r($_POST);
		$ADMIN_PERMIT_LIST = $_POST['ADMIN_PERMIT_LIST'];
		$MIKROTIK_HOST = $_POST['MIKROTIK_HOST'];
		$MIKROTIK_PASSWORD = $_POST['MIKROTIK_PASSWORD'];
		$MIKROTIK_PORT = $_POST['MIKROTIK_PORT'];
		
		$sql = "UPDATE configs SET keyvalue = '$ADMIN_PERMIT_LIST' WHERE keyname ='ADMIN_PERMIT_LIST'";
		$dataReader = Yii::app()->db->createCommand($sql)->query();
		$sql2 = "UPDATE configs SET keyvalue = '$MIKROTIK_HOST' WHERE keyname ='MIKROTIK_HOST'";
		$dataReader2 = Yii::app()->db->createCommand($sql2)->query();
		$sql3 = "UPDATE configs SET keyvalue = '$MIKROTIK_PASSWORD' WHERE keyname ='MIKROTIK_PASSWORD'";
		$dataReader3 = Yii::app()->db->createCommand($sql3)->query();
		$sql4 = "UPDATE configs SET keyvalue = '$MIKROTIK_PORT' WHERE keyname ='MIKROTIK_PORT'";
		$dataReader4 = Yii::app()->db->createCommand($sql4)->query();
		echo "Update Success";
		$this->renderPartial('Editsetting');

	}

	protected function performAjaxValidation($model)
	{
		if(isset($_POST['ajax']) && $_POST['ajax']==='config-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}
	}
}
